<template>
	<view class="content">
		<view class="header">
			<view class="title">
				碎片
			</view>
			<view class="price">
				{{walletData.fragment}}
			</view>
		</view>
		<view class="section">
			<view class="name">
				立即拒提为大王币
			</view>
			<view class="number">
				<input placeholder="请输入拒提数量（整数）" v-model="num" @input="numinput"/>
				<text @click="goall">全部拒提</text>
			</view>
		</view>
		<view class="section">
			<view class="name">
				可拒提大王币
			</view>
			<view class="number">
				{{yuanqi}}
			</view>
		</view>
		<view class="foot_btn allbtn flexs" @click="submit">
			立即拒提
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			walletData:{
				fragment:0
			},//余额
			num:"",
			yuanqi:0
		};
	},
	onShow() {
		this.getwallet()//钱包
	},
	onNavigationBarButtonTap(e) {
		uni.navigateTo({
			url:"/userPage/user/duihuanRecord"
		})
	},
	methods:{
		numinput(){
			this.yuanqi = parseInt(Number(this.num)/10)
		},
		goall(){
			this.num = this.walletData.fragment
			this.yuanqi = parseInt(Number(this.num)/10)
		},
		submit(){
			if(this.num == ''){
				uni.showToast({
					title:"请输入拒提金额",
					icon:"none"
				})
				return
			}
			let data = {
				num:this.num
			}
			this.$Request.post(this.$api.user.fragmentExchange,data).then(res => {
				uni.showToast({
					title:res.msg,
					icon:"none"
				})
				setTimeout(()=>{
					this.getwallet()//钱包
					this.num = ''
				},800)
				 clearTimeout();
			});
		},
		getwallet(){
			this.$Request.get(this.$api.user.wallet).then(res => {
				this.walletData = res.data
			});
		},
	}
};
</script>

<style lang="scss" scoped>
	.content{
		min-height: 100vh;
		background: #FFF;
		
		.foot_btn{
			width: 600rpx;
			height: 88rpx;
			color: #000;
			border-radius: 100rpx;
			margin: 132rpx auto;
		}
		
		.header{
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 54rpx;
			.title{
				font-size: 40rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}
			.price{
				font-size: 40rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				margin-top: 18rpx;
			}
		}
		.section{
			padding: 40rpx;
			.name{
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				padding-bottom: 20rpx;
			}
			.number{
				display: flex;
				align-items: center;
				text{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #1290FF;
					margin-left: 30rpx;
				}
				input{
					width: 400rpx;
					height: 50rpx;
					background: #FFFFFF;
					border: 1px solid #707070;
					border-radius: 10rpx;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #999999;
					padding-left: 20rpx;
				}
			}
			
		}
	}
</style>
